#include "comm.hpp"

// 管理管道文件
int main()
{
    Init init;

    // 打开管道
    int fd = open(FIFO_FILE,O_RDONLY);
    if(fd < 0)
    {
        perror("open");
        exit(FIFO_OPEN_ERR);
    }

    std::cout << "manager open file done" << std::endl;

    // 开始通信
    while(true)
    {
        char buffer[1024] = {0};
        int x = read(fd,buffer,sizeof(buffer));
        if(x > 0)
        {
            buffer[x] = 0;
            std::cout << "writer say# " << buffer << std::endl;
        }
        else if(x == 0)
        {
            std::cout << "writer quit, me too!\n" << std::endl;
            break;
        }
        else
            break;
    }


    return 0;
}
